/*
 * @Author: Setsuna
 * @Email: setsuna.xyz@qq.com
 * @FilePath: \src\pages\StatementOfAccount\SendStatementOfAccount\components\SelectView.tsx
 * @Date: 2022-03-14 15:33:22
 * @LastEditTime: 2022-04-29 12:29:47
 */
import React, { ReactNode } from 'react'
import { Button, Col, Row, Select } from 'antd'
import { SelectProps } from 'antd/lib/select'
import UdSelect from '@/components/UdFormControls/UdSelect'

function SelectView(props: IUdSelectProps) {
  const { options, buttonText = '预览模板', ...rest } = props

  return (
    <Row>
      <Col span={20}>
        <UdSelect allowClear={false} options={options} {...rest}></UdSelect>
      </Col>
      <Col span={3} offset={1}>
        <Button type="primary" onClick={rest.buttonClick}>
          {buttonText}
        </Button>
      </Col>
    </Row>
  )
}

const SelectViewRef = React.forwardRef((props: any, ref) => {
  return <SelectView {...props} />
})

export default React.memo(SelectViewRef)

interface IUdSelectProps extends SelectProps {
  options: { value: string; title: string }[]
  mapping?: ((value: any, index: number, array: any[]) => ReactNode) | { title: string; value: string }
  buttonText: string
  buttonClick: any
}
